fix(core): consolidate ID generation to prevent HTTP self-hosted crashes#3977
fix(core): consolidate ID generation to prevent HTTP self-hosted crashes#3977waleedlatif1 merged 4 commits intostagingfrom
Conversation
crypto.randomUUID() requires a secure context (HTTPS) in browsers, causing white-screen crashes on self-hosted HTTP deployments. This replaces all direct usage of crypto.randomUUID(), nanoid, and the uuid package with a central utility that falls back to crypto.getRandomValues() which works in all contexts. - Add generateId(), generateShortId(), isValidUuid() in @/lib/core/utils/uuid - Replace crypto.randomUUID() imports across ~220 server + client files - Replace nanoid imports with generateShortId() - Replace uuid package validate with isValidUuid() - Remove nanoid dependency from apps/sim and packages/testing - Remove browser polyfill script from layout.tsx - Update test mocks to target @/lib/core/utils/uuid - Update CLAUDE.md, AGENTS.md, cursor rules, claude rules Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview Updates a large set of API routes to use the new helpers for record IDs, request IDs, tokens, lock values, and message/run/execution IDs, and adjusts tests/mocks plus developer guidelines ( Reviewed by Cursor Bugbot for commit 7be21d2. Configure here. |
|
@greptile |
|
@cursor review |
Greptile SummaryThis PR consolidates all ID generation to a central Key changes:
Issue found: The Confidence Score: 4/5PR is safe to merge with one cleanup item: the orphaned The core fix is correct and well-implemented. The UUID v4 fallback logic is mathematically sound, the nanoid-compatible alphabet is exact, and test mocks follow project conventions. One P1 remains: the
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["ID generation call site"] --> B{"generateId() or generateShortId()"}
B --> C["apps/sim/lib/core/utils/uuid.ts"]
C --> D{"crypto.randomUUID\navailable?"}
D -->|"Yes (HTTPS or\nNode.js 20+)"| E["crypto.randomUUID()\n→ UUID v4"]
D -->|"No (HTTP browser,\nnon-secure context)"| F["crypto.getRandomValues()\n→ manual UUID v4"]
C --> G{"generateShortId()"}
G --> H["crypto.getRandomValues()\n→ 64-char alphabet"]
E --> I["UUID string"]
F --> I
H --> J["Short URL-safe ID"]
style C fill:#4ade80,stroke:#16a34a
style D fill:#fbbf24,stroke:#d97706
Reviews (2): Last reviewed commit: "fix(core): remove deprecated uuid mock h..." | Re-trigger Greptile |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit cf15265. Configure here.
|
@greptile |
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 7be21d2. Configure here.
Summary
crypto.randomUUID()requires HTTPS/secure context in browsers — crashes on self-hosted HTTP deployments with white screengenerateId()utility in@/lib/core/utils/uuidthat falls back tocrypto.getRandomValues()(works everywhere)crypto.randomUUID(),import { randomUUID } from 'crypto',nanoid, anduuidpackage usage across ~320 filesgenerateShortId()(replaces nanoid) andisValidUuid()(replaces uuid validate)nanoiddependency fromapps/simandpackages/testinglayout.tsxType of Change
Testing
crypto.randomUUID(),nanoid, oruuidimports inapps/sim/Checklist